{extend name="base"/}
{block name="main"}
<style>
    .btn-search:hover {color:#fff !important;}
</style>
<div class="Hui-article">
    <article class="cl pd-20">
        <div class="n_tab_line">
            <a href="{:url('Role/index')}" class="n_tab_list">用户组</a>
            <div class="l n_tab_add" style="width: auto">
                <button type="button"  class="btn btn-search radius"  onclick="role_add_mod()"><i class="Hui-iconfont">&#xe600;</i> 添加用户组</button>
            </div>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <form class="Huiform" method="post" action="__CONF_SITE__admin/Role/index" style=" padding: 15px;">
                <div class="text-c">
                    <input type="text" class="input-text" value="{$role_name}" style="width:250px" placeholder="输入用户组"  name="role_name">
                    <button type="submit" class="btn btn-search radius"  name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户组</button>
                </div>
            </form>
        </div>
        <table class="table table-border table-bordered table-bg">
            <thead>
            <tr class="text-c">
                <th>名称</th>
                <!--<th>权限</th>-->
                <th>描述</th>
                <th>添加时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="vo"}
            <tr class="text-c">
                <td>{$vo['role_name']}</td>
                <!--<td>{:getArrayName($vo['module_id_array'])}</td>-->
                <td>{$vo['info']|default="无"}</td>
                <td>{$vo['create_time']|date='Y-m-d H:i:s',###}</td>
                <td>
                    <a title="编辑" href="javascript:;" onclick="role_edit('{$vo.role_id}')" class="ml-5" style="text-decoration:none">编辑</a>
                    {if $vo['role_id']!=1}
                    <a title="删除" href="javascript:;" onclick="role_del('{$vo.role_id}')" class="ml-5" style="text-decoration:none">删除</a>
                    {/if}
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </article>
    <div class="n_page_no">
        {$list->render()}
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="/public/js/jquery-2.1.1.js"></script>
<script type="text/javascript">
    function role_add_mod() {
        layer.open({
            type: 2,
            area: ['900px', '700px'],
            fix: false, //不固定
            maxmin: true,
            shade:0.4,
            title: '添加用户组',
            content: '__CONF_SITE__admin/role/role_add',
            scrollbar:false,
            shadeClose:true,
        });
    }
    function role_edit(id) {
        layer.open({
            type: 2,
            area: ['900px', '700px'],
            fix: false, //不固定
            maxmin: true,
            shade:0.4,
            title: '编辑用户组',
            content: '__CONF_SITE__admin/role/role_edit&id='+id,
            scrollbar:false,
            shadeClose:true,
        });
    }
    function role_del(role_id) {
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type : "post",
                url : "__CONF_SITE__admin/role/role_del",
                data : {'role_id':role_id},
                success : function(data) {
                    console.log(data);
                    if(data['code']>0 ){
                        layer.msg('成功',{icon:1,time:1000},function () {
                            location.reload();
                        });
                    }else{
                        layer.msg('失败',{icon:5,time:1000});
                    }
                }
            });
        })
    }
</script>
{/block}